//
//  ALPJiNGpIN.m
//  AlpFM
//
//  Created by dllo on 16/1/27.
//  Copyright © 2016年 Alp. All rights reserved.
//

#import "ALPListenListCellFirst.h"
#import "ALPListenListCellSecond.h"

@interface ALPListenListCellFirst ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong)UILabel *title;      //小编推荐
@property (nonatomic, strong) UIImageView *sanjiao; //三角图标
@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) UIImageView *xijiantou; //细箭头
@property (nonatomic, strong) UILabel *gengduo;  //更多
@end

@implementation ALPListenListCellFirst


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creat];
    }
    return self;
}
-(void)creat{
    self.sanjiao = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 16, 16)];
    self.sanjiao.image = [UIImage imageNamed:@"sanjiao"];
    [self.contentView addSubview:self.sanjiao];
    
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(35, 9, 100, 20)];
    self.title.font = [UIFont boldSystemFontOfSize:16];
    self.title.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.title];
    
    self.gengduo = [[UILabel alloc]initWithFrame:CGRectMake(325, 9, 30, 20)];
    self.gengduo.text = @"更多";
    self.gengduo.textColor = [UIColor grayColor];
    self.gengduo.font = [UIFont boldSystemFontOfSize:14];
    [self.contentView addSubview:self.gengduo];
    
    self.xijiantou = [[UIImageView alloc]initWithFrame:CGRectMake(355, 9, 15, 15)];
    self.xijiantou.image = [UIImage imageNamed:@"xijiantou"];
    [self.contentView addSubview:self.xijiantou];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(325, 0, 50, 40);
    [button addTarget:self action:@selector(push:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:button];
    
    self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 40, 375, 160) style:UITableViewStylePlain];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.showsVerticalScrollIndicator = NO; //取消滚动条
    self.myTableView.scrollEnabled = NO;    //禁止滚动
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLineEtched;
    [self.contentView addSubview:self.myTableView];
    
    [self.myTableView registerClass:[ALPListenListCellSecond class] forCellReuseIdentifier:@"cell"];
    
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        ALPListenListCellSecond *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.model = _model.list[0];
        return cell;
    }else{
        ALPListenListCellSecond *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.model = _model.list[1];
        return cell;
    }
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];  //取消选中状态
    ALPThreeListenListModel *mol = [_model.list objectAtIndex:indexPath.row];
    [self.xieyiren sendID:mol.specialId contentType:mol.contentType];
}

-(void)setModel:(ALPSecondListenListModel *)model{
    _model = model;
    self.title.text = _model.title;
    [self.myTableView reloadData];
    
}

//更多按钮
-(void)push:(UIButton *)btn{
    [self.xieyiren pushMoreVC:_model.title];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
